import React ,{Suspense} from 'react'
import {Navigate,Route,Routes,BrowserRouter} from 'react-router-dom'
import routers from './router//index'
function App() {
  const rendrouter=(arr:any)=>{
    return arr && arr.map((item:any,index:number)=>{
      return <Route
        key={index}
        path={item.path}
        element={item.element?<item.element></item.element>:<Navigate to={item.to}></Navigate>}
      >
        {
          item.children&&rendrouter(item.children)
        }
      </Route>
    })
  }
  return (
    <Suspense fallback={<div>加载中...</div>}>
      <BrowserRouter>
        <Routes>
              {
                rendrouter(routers)
              }
        </Routes>
      </BrowserRouter>
    </Suspense>
  )
}

export default App
